var ScanDirAssistant = function() {
}

ScanDirAssistant.prototype.run = function(future) {
	var args = this.controller.args;
	if(!args.path) {
		setError(future, "parameter path must be string");
	} else {
		path.exists(args.path, function(exists) {
			if(exists) {
				var files = fs.readdirSync(args.path);
				var res = [];
				for(var i = 0; i < files.length; i++) {
					if(/\[object Object\]/.test(files[i]))
						continue;
					if(!args.showHiddenFiles && /^\..*$/.test(files[i]))
					   continue;

					var stat = fs.statSync(path.join(args.path, files[i]));
					res.push({
						name:		files[i],
						isDir:		stat.isDirectory(),
						isFile:		stat.isFile(),
						isSpecial:	stat.isBlockDevice() || stat.isCharacterDevice() || stat.isFIFO() || stat.isSocket(),
						size:		stat.size,
						atime:		stat.atime,
						mtime:		stat.mtime,
						ctime:		stat.ctime
					});
				}
				future.result = {
					files:	res
				}
			} else {
				setError("path does not exist");
			}
		});
	}
}
